package com.example.demo.serviceImpl;

import com.example.demo.bean.ListBean;
import com.example.demo.bean.SongBean;
import com.example.demo.mapper.ListMapper;
import com.example.demo.service.ListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ListServiceImpl implements ListService {
    @Autowired
    private ListMapper listMapper;
    //新建歌单
    @Override
    public boolean createList(ListBean listBean) {
        return listMapper.creatList(listBean) > 0 ? true : false;
    }
    //删除歌单
    @Override
    public boolean deleteList(int lid){
        return listMapper.deleteList(lid)>0?true:false;
    }
    //修改歌单信息
    @Override
    public boolean changeList(int lid,String list_name,String introduce){
        return listMapper.changeList(lid,list_name,introduce)>0?true:false;
    }
    //查询歌单是否存在
    @Override
    public boolean checkList(int lid){
        List<ListBean> listBeans = listMapper.checkList(lid);
        if(listBeans==null||listBeans.size()==0){
            return false;
        }
        return true;
    }
    //获取歌单
    @Override
    public ListBean getList(int uid,String listName,String creationTime){
        return listMapper.getList(uid,listName,creationTime);
    }
    //获取用户歌单
    @Override
    public List<ListBean> getUserLists(int uid){
        return listMapper.getUserLists(uid);
    }

    //获取歌单内容
    @Override
    public List<SongBean> listGetSongs(int lid){
        return listMapper.getListSongs(lid);
    }
    //新增歌单内容
    @Override
    public boolean listAddSong(int lid,int sid){
        return listMapper.listAddSong(lid,sid)>0?true:false;
    }
    //删除歌单内容
    @Override
    public boolean listDelSong(int lid,int sid){
        return listMapper.listDelSong(lid, sid)>0?true:false;
    }
    //查询歌单内容
    @Override
    public SongBean listFindSong(int lid,int sid){
        return listMapper.listFindSong(lid,sid);
    }

}
